
from . import base_parser

class MyHTMLParser(base_parser.BaseHTMLParser):
    HOST = 'http://www.hnggzy.com/hnsggzy/jyxx/002002/002002001/'
    TITLE = '河南省公共资源交易中心'
    #HOST = 'http://www.hnggzy.com/hnsggzy/infodetail/?infoid=032d5eaf-251a-4f4c-8d73-3120cb4b9f3e&categoryNum=002002001'
    

    def __init__(self, host=None):
        
        if not host:
            host = self.HOST
        
        super(MyHTMLParser, self).__init__(host=host )
        self.host = host
        self.title = self.TITLE

        self.result_meta = {
            'len': 5,
            'href': ( 2, 'a', 'href' ),
            'title': ( 2, 'a', 'title' ),
            'date':  ( 3, 'font', 'text' ),
        }
        
        
    def parser(self, page_no=None ):
        url = page_no and self.host + '?Paging=' + str(page_no)
        return super(MyHTMLParser, self).parser(url=url)

    def handle_result_date(self, date):
        return date.strip()[1:-1]

    def handle_result_href(self, href):
        return 'www.hnggzy.com' + href


